package com.nuanshui.heatedloan.credit.pay.validation;

import com.nuanshui.heatedloan.credit.pay.PayRequest;
import com.nuanshui.heatedloan.credit.pay.execute.OrderEntityContainer;

import java.util.List;

public class PayValidationFacade extends OrderEntityContainer<PayValidationWrapper> {

    public ValidationResult execute(String group, PayRequest request) {
        List<PayValidationWrapper> list = this.getGroup(group);


        ValidationResult result = null;
        for (PayValidationWrapper item : list) {

            result=item.getTarget().validate(request);

            if(!result.getCode().equals(ValidationResultCode.VALIDATION_SUCCESS))
            {
                break;
            }
        }

        return result;
    }

}
